package cn.sofwin.day0327;

public class Test04 {
    public static void main(String[] args) {
        Thread special = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                System.out.println("特需号：" + (i+1) +"号病人在看病！");
                sleepThread(20);
            }
        });
        Thread nomal = new Thread(() -> {
            for (int i = 0; i < 50; i++) {
                System.out.println("普通号：" + (i+1) +"号病人在看病！");
                sleepThread(10);
                if (i == 9) {
                    try {
                        special.join();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }

        });

        nomal.setPriority(1);
        special.setPriority(6);
        nomal.start();
        special.start();
    }

    static void sleepThread(int n){
        try {
            Thread.sleep(n);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
